// CommodityMapper.java (数据访问层)
package com.ywb.mapper;

import com.ywb.pojo.Commodity;
import com.ywb.pojo.CommodityQueryParam;
import com.ywb.pojo.JobOption;
import org.apache.ibatis.annotations.*;

import java.util.List;
import java.util.Map;

@Mapper
public interface CommodityMapper {



    @Select("SELECT * FROM commodity ORDER BY commodity_id")
    List<Commodity> findAll();

    @Delete("DELETE FROM commodity WHERE commodity_id = #{id}")
    void deleteById(Integer id);

    @Insert("INSERT INTO commodity(commodity_name, category_id) VALUES(#{commodityName}, #{categoryId})")
    void insert(Commodity commodity);

    @Select("SELECT * FROM commodity WHERE commodity_id = #{id}")
    Commodity getById(Integer id);

    @Update("UPDATE commodity SET commodity_name = #{commodityName}, category_id = #{categoryId} WHERE commodity_id = #{commodityId}")
    void update(Commodity commodity);

    @Delete("DELETE FROM commodity WHERE category_id = #{id}")
    void deleteByCategoryId(Integer id);

    List<Commodity> list(CommodityQueryParam commodityQueryParam);

    List<Map<String,Object>> countContinentTradeData();

    List<Map<String, Object>> countCommodityData();
}